package 线程状态.线程休眠;

import java.text.SimpleDateFormat;
import java.util.Date;

public class test_模拟时钟 {
    public static void main(String[] args) {
        Date sj = new Date(System.currentTimeMillis());//获取系统当前时间
        while (true){
            System.out.println(new SimpleDateFormat("HH:mm:ss").format(sj));//设置时间显示格式
            try {
                Thread.sleep(1000);
                sj = new Date(System.currentTimeMillis());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
